/*
 * Middleware
 * Copyright (C) 2010/11
 * Marco Buzzanca, Davide Giuseppe Monaco, Riccardo Pulvirenti, Giuseppe Ravidà,
 * Andrea Tino
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANDABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses
 */

/*!
 * File: xml_incapsulator.hpp
 */

#ifndef _XML_INCAPSULATOR_HPP_
#define _XML_INCAPSULATOR_HPP_

#include <iostream>
#include <string>

#include "workflow.hpp"
#include "task_descriptor.hpp"
#include "worker_descriptor.hpp" /* Contains capabilities too */
#include "address.hpp"

// Class definitions
namespace middleware {
namespace xml {
/*!
 * Serves as intermediate object for logging and other classes
 */
class XmlIncapsulator {
public:
	/*!
	 * Constructor
	 */
	XmlIncapsulator() {

	}
	/*!
	 * Destrucotr
	 */
	~XmlIncapsulator() {

	}
	/*!
	 * Getter for xml
	 */
	std::string GetXml() const {
		return this->_xml;
	}
	/*!
	 * Resets the string
	 */
	void Reset() {
		this->_xml = std::string("");
	}
	/*!
	 * Operators to render classes: supposition: all objects do implement the
	 * XmlTranslator interface.
	 */
	XmlIncapsulator& operator<<(const Workflow& wf) {
		this->_xml = this->_xml + wf.ToXml();
		return *this;
	}
	XmlIncapsulator& operator<<(const WorkerDescriptor& wd) {
		this->_xml = this->_xml + wd.ToXml();
		return *this;
	}
	XmlIncapsulator& operator<<(const TaskDescriptor& td) {
		this->_xml = this->_xml + td.ToXml();
		return *this;
	}
	XmlIncapsulator& operator<<(const Address& ad) {
		this->_xml = this->_xml + ad.ToXml();
		return *this;
	}
private:
	/*!
	 * Stores xml
	 */
	std::string _xml;
}; /* XmlIncapsulator */
} /* xml */
} /* middleware */

#endif
